diff --git a/src/tools/Preferences.cs b/src/tools/Preferences.cs
index 192bf14..775a83e 100644
--- a/src/tools/Preferences.cs
+++ b/src/tools/Preferences.cs
@@ -132,6 +132,7 @@ public class Preferences
 		xml.Indentation = 1;
 		xml.IndentChar = '\t';
 
+		xml.WriteStartDocument(true);
 		xml.WriteStartElement(null, "preferences", null);
 
 		foreach (DictionaryEntry entry in prefs) {
diff --git a/src/tools/Session.cs b/src/tools/Session.cs
index 7980cc0..5184632 100644
--- a/src/tools/Session.cs
+++ b/src/tools/Session.cs
@@ -77,6 +77,7 @@ public class Session
 		xml.Indentation = 1;
 		xml.IndentChar = '\t';
 
+		xml.WriteStartDocument(true);
 		xml.WriteStartElement(null, "session", null);
 
 		xml.WriteStartElement(null, "windowheight", null);
@@ -194,4 +195,4 @@ public class SessionFileInfo
 	}
 }
 
-} // end namespace
\ No newline at end of file
+} // end namespace
